﻿using System.Collections.Generic;

namespace BLE_Keypad_Tool.Classes
{
	internal class KeyCode
	{
		private static readonly Dictionary<int, string> _key_codes = new Dictionary<int, string>()
		{
			{ 0x00, "" },

			#region Letters and Numbers
			{ 0x04, "A" },
			{ 0x05, "B" },
			{ 0x06, "C" },
			{ 0x07, "D" },
			{ 0x08, "E" },
			{ 0x09, "F" },
			{ 0x0A, "G" },
			{ 0x0B, "H" },
			{ 0x0C, "I" },
			{ 0x0D, "J" },
			{ 0x0E, "K" },
			{ 0x0F, "L" },
			{ 0x10, "M" },
			{ 0x11, "N" },
			{ 0x12, "O" },
			{ 0x13, "P" },
			{ 0x14, "Q" },
			{ 0x15, "R" },
			{ 0x16, "S" },
			{ 0x17, "T" },
			{ 0x18, "U" },
			{ 0x19, "V" },
			{ 0x1A, "W" },
			{ 0x1B, "X" },
			{ 0x1C, "Y" },
			{ 0x1D, "Z" },

			{ 0x1E, "1" }, // 1!
			{ 0x1F, "2" }, // 2@
			{ 0x20, "3" }, // 3#
			{ 0x21, "4" }, // 4$
			{ 0x22, "5" }, // 5%
			{ 0x23, "6" }, // 6^
			{ 0x24, "7" }, // 7&
			{ 0x25, "8" }, // 8*
			{ 0x26, "9" }, // 9(
			{ 0x27, "0" }, // 0)	
			# endregion

			#region F Keys
			{ 0x3A, "F1" },
			{ 0x3B, "F2" },
			{ 0x3C, "F3" },
			{ 0x3D, "F4" },
			{ 0x3E, "F5" },
			{ 0x3F, "F6" },
			{ 0x40, "F7" },
			{ 0x41, "F8" },
			{ 0x42, "F9" },
			{ 0x43, "F10" },
			{ 0x44, "F11" },
			{ 0x45, "F12" },
			// { 0x68, "F13" },
			// { 0x69, "F14" },
			// { 0x6A, "F15" },
			// { 0x6B, "F16" },
			// { 0x6C, "F17" },
			// { 0x6D, "F18" },
			// { 0x6E, "F19" },
			// { 0x6F, "F20" },
			// { 0x70, "F21" },
			// { 0x71, "F22" },
			// { 0x72, "F23" },
			// { 0x73, "F24" },
			# endregion

			#region Punctuation
			{ 0x28, "Enter" },
			{ 0x29, "Esc" },
			{ 0x2A, "Back" },
			{ 0x2B, "Tab" },
			{ 0x2C, "Space" },
			{ 0x2D, "-" }, // -_
			{ 0x2E, "=" }, // =+
			{ 0x2F, "[" }, // [{
			{ 0x30, "]" }, // ]}
			{ 0x31, "\\" }, // \|
			// { 0x32, "#" }, // Non-US #~
			{ 0x33, ";" }, // ;:
			{ 0x34, "\"" }, // '"
			{ 0x35, "~" }, // `~
			{ 0x36, "," }, // ,<
			{ 0x37, "." }, // .>
			{ 0x38, "?" }, // /?
			//{ 0x64, "\\" }, // Non-US \|
			# endregion

			#region Lock Keys
			{ 0x39, "CapsLock" },
			{ 0x47, "ScrLk" },
			{ 0x53, "Num" },
			#endregion

			#region Modifiers
			{ 0xE0, "LCtrl" },
			{ 0xE1, "LShift" },
			{ 0xE2, "LAlt" },
			{ 0xE3, "LGUI" }, // GUI (Windows/Command/Meta key)
			{ 0xE4, "RCtrl" },
			{ 0xE5, "RShift" },
			{ 0xE6, "RAlt" },
			{ 0xE7, "RGUI" },
			#endregion

			#region Commands
			{ 0x46, "PrtSc" },
			{ 0x48, "Pause" },
			{ 0x49, "Ins" },
			{ 0x4A, "Home" },
			{ 0x4B, "PgUp" },
			{ 0x4C, "Del" },
			{ 0x4D, "End" },
			{ 0x4E, "PgDn" },
			{ 0x65, "Menu" }, // Application (Windows Menu Key)
			# endregion

			#region Directions
			{ 0x4F, "→" },
			{ 0x50, "←" },
			{ 0x51, "↓" },
			{ 0x52, "↑" },
			#endregion
		};

		//#region Number Pad
		//PAD_SLASH    = const(0x54) # /
		//PAD_ASTERISK = const(0x55) # *
		//PAD_MINUS    = const(0x56) # -
		//PAD_PLUS     = const(0x57) # +
		//PAD_ENTER    = const(0x58)
		//PAD_NUM_1    = P1 = const(0x59) # 1 and End
		//PAD_NUM_2    = P2 = const(0x5A) # 2 and Down Arrow
		//PAD_NUM_3    = P3 = const(0x5B) # 3 and Page Down
		//PAD_NUM_4    = P4 = const(0x5C) # 4 and Left Arrow
		//PAD_NUM_5    = P5 = const(0x5D) # 5
		//PAD_NUM_6    = P6 = const(0x5E) # 6 and Right Arrow
		//PAD_NUM_7    = P7 = const(0x5F) # 7 and Home
		//PAD_NUM_8    = P8 = const(0x60) # 8 and Up Arrow
		//PAD_NUM_9    = P9 = const(0x61) # 9 and Page Up
		//PAD_NUM_0    = P0 = const(0x62) # 0 and Insert
		//PAD_DOT      = const(0x63) # . and Delete
		//# endregion

		public KeyCode()
		{
		}

		public static string get_keycode_name(int keycode)
		{
			return _key_codes[keycode];
		}
	}
}
